package EjemplosEventosBasicos;

import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.ImageIcon;
import javax.swing.JDialog;

public class WindowsListener implements WindowListener{

	private JDialog dialog;
	ImageIcon icon = new ImageIcon("caballo_negro.gif");
	
	public WindowsListener(JDialog dialog){
		this.dialog = dialog;
	}
	
	
	public void windowActivated(WindowEvent e) {
		System.out.println("Activated");
	}

	public void windowClosed(WindowEvent e) {
		//Dialog.dispose
		System.out.println("Despues del dispose se ejecuta Closed");
	}

	public void windowClosing(WindowEvent e) {
		//Funciona simplemente pulsando X de la ventana.
		System.out.println("Closing");
		dialog.dispose(); 
		//dialog.setVisible(false); Deactivated sigue funcionando con esta sentencia, Closed NO
	}

	public void windowDeactivated(WindowEvent e) {
		System.out.println("Deactivated");
	}

	public void windowDeiconified(WindowEvent e) {
		//No se ejecuta nunca
		System.out.println("Ventana maximizada");
	}

	public void windowIconified(WindowEvent e) {
		//No se ejecuta nunca
		System.out.println("Ventana minimizada");
	}

	public void windowOpened(WindowEvent e) {
		System.out.println("Ventana abierta por primera vez");
		
	}

}
